﻿<%@ Page Language="C#" MasterPageFile="~/Home.Master" AutoEventWireup="true" Theme="CssTheme"
    CodeBehind="UserAdministrations.aspx.cs" Inherits="SLIITPro.SysUsers.UserAdministrations"
    Title="Administration Page" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="ContentAdmin" ContentPlaceHolderID="BodyContentPlaceHolder" runat="server">
    <div class="grid">
        <div class="rounded">
            <div class="top-outer">
                <div class="top-inner">
                    <div class="top">
                        <h2>
                            Users Administration</h2>
                    </div>
                </div>
            </div>
            <div class="mid-outer">
                <div class="mid-inner">
                    <div class="mid">
                        <asp:UpdatePanel ID="upAdministration" runat="server">
                            <ContentTemplate>
                                <asp:GridView ID="grdUsers" runat="server" AutoGenerateColumns="False" AllowPaging="True"
                                    GridLines="None" CssClass="datatable" DataKeyNames="UserId" DataSourceID="SqlDataSourceUsers"
                                    OnRowDataBound="GridView1_RowDataBound" ShowFooter="true">
                                    <PagerTemplate>
                                        <asp:Label ID="Label1" runat="server" Text="Show rows:" />
                                        <asp:DropDownList ID="ddlPageSize" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddl_SelectedIndexChanged">
                                            <asp:ListItem Value="5" />
                                            <asp:ListItem Value="10" />
                                            <asp:ListItem Value="15" />
                                            <asp:ListItem Value="20" />
                                        </asp:DropDownList>
                                        &nbsp; Page
                                        <asp:TextBox ID="txtGoToPage" runat="server" AutoPostBack="true" OnTextChanged="GoToPage_TextChanged"
                                            CssClass="gotopage" />
                                        of
                                        <asp:Label ID="lblTotalNumberOfPages" runat="server" />
                                        &nbsp;
                                        <asp:Button ID="btnprev" runat="server" CommandName="Page" ToolTip="Previous Page"
                                            CommandArgument="Prev" CssClass="previous" />
                                        <asp:Button ID="btnNext" runat="server" CommandName="Page" ToolTip="Next Page" CommandArgument="Next"
                                            CssClass="next" />
                                    </PagerTemplate>
                                    <Columns>
                                        <asp:TemplateField>
                                            <ItemTemplate>
                                                <asp:CheckBox ID="chkSelect" runat="server" />
                                            </ItemTemplate>
                                            <ItemStyle CssClass="command" />
                                        </asp:TemplateField>
                                        <asp:BoundField DataField="UserId" HeaderText="ID" InsertVisible="False" ReadOnly="True"
                                            SortExpression="UserId" />
                                        <asp:BoundField DataField="FirstName" HeaderText="First Name" SortExpression="FirstName" />
                                        <asp:BoundField DataField="LastName" HeaderText="Last Name" SortExpression="LastName" />
                                        <asp:BoundField DataField="Country" HeaderText="Country" SortExpression="Country" />
                                        <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
                                        <asp:BoundField DataField="ActivationCode" HeaderText="Activation Code" SortExpression="ActivationCode" />
                                        <asp:TemplateField HeaderText="User Activation">
                                            <ItemTemplate>
                                                <asp:LinkButton ID="HyperLinkApprove" runat="server" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "UserId") %>'
                                                    ForeColor='<%# GetLinkColor(Convert.ToBoolean(DataBinder.Eval(Container.DataItem, "IsActivated"))) %>'
                                                    OnClick="HyperLinkActivate_Click" Text='<%# GetLinkText(Convert.ToBoolean(DataBinder.Eval(Container.DataItem, "IsActivated"))) %>'>
                                                </asp:LinkButton>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:BoundField DataField="UserType" HeaderText="User Type" SortExpression="UserType"
                                            HtmlEncode="false" DataFormatString="<a href='?UserType={0}'>{0}</a>" />
                                    </Columns>
                                    <PagerStyle CssClass="pager-row" />
                                    <RowStyle CssClass="row" />
                                    <FooterStyle CssClass="footer" />
                                </asp:GridView>
                                <asp:SqlDataSource ID="SqlDataSourceUsers" runat="server" ConnectionString="<%$ ConnectionStrings:SLIITProConnectionString %>"
                                    SelectCommand="SELECT [UserId],[FirstName],[LastName],[Street],[City],[Province],[Country],[Email],[Password],[UserKey],[ActivationCode],[IsActivated],[CreatedAt],[UpdatedAt],[UserType],[Phone],[Fax]FROM [Users]"
                                    FilterExpression="UserType like '{0}%'">
                                    <FilterParameters>
                                        <asp:QueryStringParameter QueryStringField="UserType" Name="UserType" DefaultValue="%"
                                            ConvertEmptyStringToNull="true" Type="String" />
                                    </FilterParameters>
                                </asp:SqlDataSource>
                                <br />
                                <asp:Label ID="lblSMessage" runat="server" 
                                    Style="font-size: small; color: #3366FF;"></asp:Label>
                                <div class="buttondiv">
                                    <asp:Button ID="btnSelectAll" runat="server" Text="Select All" CssClass="cssbutton"
                                        Width="75px" OnClick="btnSelectAll_Click" />
                                    <asp:Button ID="btnBan" runat="server" Text="Change Activation Mode" CssClass="cssbutton"
                                        Width="150px" OnClientClick="return confirm('Are you sure want change activation mode?');"
                                        OnClick="btnBan_Click" />
                                    <asp:Button ID="btnDelete" runat="server" Text="Delete" CssClass="cssbutton" Width="75px"
                                        OnClientClick="return confirm('Are you sure want to delete this record?');" OnClick="btnDelete_Click" />
                                </div>
                            </ContentTemplate>
                        </asp:UpdatePanel>
                    </div>
                </div>
            </div>
            <div class="bottom-outer">
                <div class="bottom-inner">
                    <div class="bottom">
                    </div>
                </div>
            </div>
        </div>
    </div>
</asp:Content>
